use the_world_game_core::{Worker, WorkerContextImpl};
use the_world_game_derive::*;
use std::collections::{HashMap, HashSet};
use crate::location::LocationManager;

pub struct Game {
    pub(crate) store: HashMap<&'static str, Vec<u8>>,
    // 本轮已经处理的协程存储
    pub(crate) handle_store_set: HashSet<&'static str>,
}

impl Game {
    pub fn new() -> Self {
        Game {
            store: HashMap::new(),
            handle_store_set: HashSet::new(),
        }
    }
}


impl Worker for Game {
    type Context = WorkerContextImpl<Self>;

    fn started(&mut self, _ctx: &mut Self::Context) {
        println!("游戏game结构启动");

        // 启动定位服务
        let location_manager = LocationManager::new();
        location_manager.run(None);
    }

    fn stopped(&mut self, _ctx: &mut Self::Context) {
        println!("struct game关闭");
    }
}

#[derive(Message)]
struct StartMsg {}

// 游戏启动信息
#[derive(Message)]
pub struct GameStartMsg {
    // 游戏id
    pub id: usize,
    // 是否新游戏
    pub new_game: bool,
    // 存档
    pub load: Option<Vec<u8>>,
}


